product list =[
    ('华为p30',3800),
    ('Mac Pro',16000),
    ('Crabs',88),
    ('Bike',800),
    ('watch',100050),
    ('head first python',128),
    ('book',100)

    ]
shopping_car = []

zhifubao = input("请输入支付宝余额")
while True:
    if zhifubao.isdigit():
        #检测是否输入的是数字，不然会报错
        zhifubao = int(zhifubao)
        for iyem in product_list:
            print(product_list.index(item),item)
        choice = input("请输入商品编号")
        if choice.isdigit():
            choice = int(choice)
            if choice >=0 and choice <8:
                if zhifubao > product_list[choice][1]:
                    zhifubao = zhifubao - product_list[choice][1]
                    shopping_car = shopping_car.append(product_list[choice])
                    print(zhifubao)
                else:
                    print("请你按q退出")
            else:
                print("请你按q退出")
        elif choice =='q':
            print(zhifubao)
            print(shopping_car)
            break
        else:
            print("请你按q退出")
    else:
        print("请你重新输入一个数字")
